function dt=create_dt(filename)

%CREATE_DT created dt data strictire from single tab-delimited file
%Syntax: dt=create_dt(filename)
%Description: filename indicates a tab-deliminetd file where
%   1. The first column contains case ref name.
%   2. The first row contains variable names.
%   3. The last column contains binary outcomes.
%   4. All other columns contain numerical values of
%      the independent variables. 
%
% Jonas Almeida, 29 Aug 2006

fid=fopen(filename);

%Read header with sample names
lala=fgetl(fid);dt.vars=eval(['{''',regexprep(lala(2:end),'\t',''','''),'''}']);
if lala(1)~=9;dt.vars(1)=[];end %if the column name is not missing remove the first label as it is not that of a variable
%Read data
dt.data=[];dt.samples='';
i=0;
while ~feof(fid)
    i=i+1;
    lala=fgetl(fid);
    [a b c d e]=regexp(lala,'([^\t]+)\t(.*)');
    dt.samples=[dt.samples,e{1}(1)];
    try
    dt.data=[dt.data;str2num(e{1}{2})];
    catch
        disp(':-O')
    end
end
fclose (fid);

dt.x=dt.data(:,1:end-2); %values of independent variables
dt.y=dt.data(:,end-1); %value of dependent variable
dt.dead=dt.data(:,end); %censuring variable <<< if this does nto apply then just fill last column with 1s
dt.nx=dt.x; % for now, normalized data is the same as raw data
